package reit.ass3;


/**
 * The Class AssetContent.
 */
class AssetContent {
	/** the maxumum health an asset content can have. */
	public static final float MAX_HEALTH = 100;

	/** The m name. */
	private final String mName;

	/** The  health. */
	private Float mHealth;

	/** The  repair cost multiplier. */
	private final float mRepairCostMultiplier;

	/**
	 * Instantiates a new asset content.
	 *
	 * @param name the name
	 * @param repairMultiplier the repair multiplier
	 */
	AssetContent(final String name, final float repairMultiplier) {
		this.mName = name;
		this.mHealth = new Float(AssetContent.MAX_HEALTH);
		this.mRepairCostMultiplier = repairMultiplier;
	}

	/**
	 * Gets the repair cost multiplier.
	 *
	 * @return the mRepairCostMultiplier
	 */
	public float getRepairCostMultiplier() {
		return mRepairCostMultiplier;
	}


	/**
	 * Gets the name.
	 *
	 * @return the mName
	 */
	public String getName() {
		return mName;
	}

	/**
	 * Gets the health.
	 *
	 * @return the health
	 */
	public synchronized float getHealth(){
		return mHealth;
	}

	/**
	 * Fixes the asset content
	 */
	public synchronized void fix(){
		this.mHealth =  new Float(AssetContent.MAX_HEALTH);
	}

	/**
	 * Cause damage.
	 *
	 * @param damageToCause the damage to cause to assetcontent
	 */
	public void causeDamage(final float damageToCause) {
		if (this.mHealth - damageToCause < 0){
			this.mHealth = new Float(0);
		}
		else 
			this.mHealth = this.mHealth - damageToCause;

	}

}
